package cn.com.frame.app.controller;

import cn.com.frame.commom.web.BaseController;
import cn.com.frame.commom.web.RespData;
import cn.com.frame.core.job.GdMapJob;
import cn.com.frame.core.job.QuartzManager;
import org.quartz.JobDataMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/job")
public class JobController extends BaseController {

    @Autowired
    private QuartzManager quartzManager;

    @GetMapping("/add")
    public RespData getPaddageData(@RequestParam("name")String name){
        JobDataMap newJobDataMap = new JobDataMap();
        newJobDataMap.put("key",name);
        quartzManager.addJob(name, GdMapJob.class,"0 0/1 * * * ?",0, newJobDataMap);
        return reSuccess("OK");
    }

    @GetMapping("/del")
    public RespData del(@RequestParam("name")String name){
        System.out.println("删除job="+name);
        quartzManager.deleteJob(name);
        return reSuccess("OK");
    }


}
